diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 7 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 2 | ||||
-rw-r--r-- | test/files/neg/t0590.check | 5 | ||||
-rw-r--r-- | test/files/neg/t0590.scala (renamed from test/pending/pos/t0590.scala) | 2 |
4 files changed, 14 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index c6e069bf01..a936353546 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1247,6 +1247,13 @@ trait Infer { sym.isAbstractType && sym.owner.isTerm } + /** A traverser to collect type parameters referred to in a type + */ + object freeTypeParametersNoSkolems extends SymCollector { + protected def includeCondition(sym: Symbol): Boolean = + sym.isTypeParameter && sym.owner.isTerm + } + object typeRefs extends SymCollector { protected def includeCondition(sym: Symbol): Boolean = true } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 701b8e5f72..aec92302f4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3409,7 +3409,7 @@ trait Typers { self: Analyzer => case _ => tp } def stripped(tp: Type): Type = { - val tparams = freeTypeParamsOfTerms.collect(tp) + val tparams = freeTypeParametersNoSkolems.collect(tp) tp.subst(tparams, tparams map (t => WildcardType)) } def sum(xs: List[Int]) = (0 /: xs)(_ + _) diff --git a/test/files/neg/t0590.check b/test/files/neg/t0590.check new file mode 100644 index 0000000000..b928c1cb76 --- /dev/null +++ b/test/files/neg/t0590.check @@ -0,0 +1,5 @@ +t0590.scala:2: error: diverging implicit expansion for type (Null(null)) => T +starting with method foo in object Test + implicit def foo[T] : T = null + ^ +one error found diff --git a/test/pending/pos/t0590.scala b/test/files/neg/t0590.scala index ee75a7d339..3416ade355 100644 --- a/test/pending/pos/t0590.scala +++ b/test/files/neg/t0590.scala @@ -1,3 +1,3 @@ object Test { implicit def foo[T] : T = null -}
\ No newline at end of file +} |