• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Generics Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Generics Problem


  • Subject: Re: Generics Problem
  • From: Quincey Morris <email@hidden>
  • Date: Sat, 19 Sep 2015 18:26:20 +0000

On Sep 19, 2015, at 10:54 , Michael de Haan  <email@hidden> wrote:
>
> func createMOforEntityName<T, U >(entityName:String, context:NSManagedObjectContext, key:String, keyAttribute: U) -> (Bool, T) {
>
>        guard let mo:T =  self.moExistsWith(entityName, key:key, keyAttribute: keyAttribute) else {

It looks like Swift is incapable of resolving the specialization of U when there is more than one generic type specifier:

> class A
> {
> 	func a<T,U> (p: U) -> T
> 	{
> 		b (p)
> 	}
> 	func a1<U> (p: U)
> 	{
> 		b (p)
> 	}
> 	func b<U> (q: U)
> 	{
> 		print (q)
> 	}
> }
>
> func z ()
> {
> 	A ().a ("aa”) // error: cannot invoke 'a' with an argument list of type '(String)’  // note: expected an argument list of type '(U)'
> 	A ().a1 ("aa”) // (just fine)
> }

I’ve seen other cases where multiple generic type specifiers caused Swift to decide it’s too hard to understand what you want. They seem to get fixed over time. Sounds like you need a bug report, and an unsatisfying temporary workaround.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Generics Problem
      • From: Jens Alfke <email@hidden>
References: 
 >Generics Problem (From: Michael de Haan  <email@hidden>)

  • Prev by Date: Generics Problem
  • Next by Date: Re: Generics Problem
  • Previous by thread: Generics Problem
  • Next by thread: Re: Generics Problem
  • Index(es):
    • Date
    • Thread