Permalink
Browse files

No bounds-driven inference for the named.

This is a variation on the previous commit which excludes
named type parameters, so this works

  def f(x: Class[_]) = x.foo.bar

But this does not:

  def f[T](x: Class[T]) = x.foo.bar

This seems undesirable to me, but I offer it in case it makes
the patch more attractive to others.
  • Loading branch information...
1 parent e28c3ed commit b4751a679a1e01d1d8826c4c2d68af269a1c0443 @paulp paulp committed May 14, 2013
@@ -4914,6 +4914,7 @@ trait Typers extends Adaptations with Tags {
&& !tparam.isFBounded /* SI-2251 */
&& !tparam.isHigherOrderTypeParameter
&& !(abounds.hi <:< tbounds.hi)
+ && asym.isSynthetic /* this limits us to placeholder tparams, excluding named ones */
)
arg match {
case Bind(_, _) => enhanceBounds()
@@ -1,5 +1,8 @@
-t5687.scala:20: error: overriding type Repr in class Template with bounds[T <: AnyRef] <: Template[T];
+t5687.scala:4: error: type arguments [T] do not conform to class Template's type parameter bounds [T <: AnyRef]
+ type Repr[T]<:Template[T]
+ ^
+t5687.scala:20: error: overriding type Repr in class Template with bounds[T] <: Template[T];
type Repr has incompatible type
type Repr = CurveTemplate[T]
^
-one error found
+two errors found
View
@@ -5,15 +5,15 @@ class Flooz[A >: Null <: SomeClass, T >: Null <: A](var value: T)
class A {
def f1(i:MyClass[_]) = i.myValue.intValue
def f2(i:MyClass[_ <: SomeClass]) = i.myValue.intValue
- def f3[T](i: MyClass[T]) = i.myValue.intValue
+ // def f3[T](i: MyClass[T]) = i.myValue.intValue
def f4[T <: SomeClass](i: MyClass[T]) = i.myValue.intValue
- def f5[T >: Null](i: MyClass[T]) = i.myValue.intValue
- def f6[T >: Null <: String](i: MyClass[T]) = i.myValue.intValue + i.myValue.charAt(0)
+ // def f5[T >: Null](i: MyClass[T]) = i.myValue.intValue
+ // def f6[T >: Null <: String](i: MyClass[T]) = i.myValue.intValue + i.myValue.charAt(0)
- def g1[A, T](x: Flooz[A, T]) = { x.value = null ; x.value.intValue }
+ // def g1[A, T](x: Flooz[A, T]) = { x.value = null ; x.value.intValue }
def g2(x: Flooz[_, _]) = { x.value = null ; x.value.intValue }
class MyClass2(x: MyClass[_]) { val p = x.myValue.intValue }
- class MyClass3[T <: String](x: MyClass[T]) { val p = x.myValue.intValue + x.myValue.length }
- class MyClass4[T >: Null](x: MyClass[T]) { val p = x.myValue.intValue }
+ // class MyClass3[T <: String](x: MyClass[T]) { val p = x.myValue.intValue + x.myValue.length }
+ // class MyClass4[T >: Null](x: MyClass[T]) { val p = x.myValue.intValue }
}

0 comments on commit b4751a6

Please sign in to comment.