diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 7 | ||||
-rw-r--r-- | test/files/jvm/interpreter.check | 4 | ||||
-rw-r--r-- | test/files/neg/t3507.check | 2 |
4 files changed, 10 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 88cecbd402..1bd2487089 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -572,7 +572,7 @@ trait Infer { tparam -> Some( if (targ.typeSymbol == RepeatedParamClass) targ.baseType(SeqClass) else if (targ.typeSymbol == JavaRepeatedParamClass) targ.baseType(ArrayClass) - else if (targ.typeSymbol.isModuleClass) targ // this infers Foo.type instead of "object Foo" + else if (targ.typeSymbol.isModuleClass) targ // this infers Foo.type instead of "object Foo" (see also widenIfNecessary) else targ.widen ) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index c5f32a344f..fddf115730 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -630,9 +630,14 @@ trait Namers { self: Analyzer => case _ => false } + val tpe1 = tpe.deconst val tpe2 = tpe1.widen - if (sym.isVariable || sym.isMethod && !sym.hasAccessorFlag) + + // This infers Foo.type instead of "object Foo" + // See Infer#adjustTypeArgs for the polymorphic case. + if (tpe.typeSymbolDirect.isModuleClass) tpe1 + else if (sym.isVariable || sym.isMethod && !sym.hasAccessorFlag) if (tpe2 <:< pt) tpe2 else tpe1 else if (isHidden(tpe)) tpe2 // In an attempt to make pattern matches involving method local vals diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check index 25804a3a60..42a8ae8855 100644 --- a/test/files/jvm/interpreter.check +++ b/test/files/jvm/interpreter.check @@ -370,5 +370,5 @@ plusOne: (x: Int)Int res0: Int = 6 res1: java.lang.String = after reset <console>:8: error: not found: value plusOne - plusOne(5) // should be undefined now - ^ + plusOne(5) // should be undefined now + ^ diff --git a/test/files/neg/t3507.check b/test/files/neg/t3507.check index ab38280c1f..8e538e4a8b 100644 --- a/test/files/neg/t3507.check +++ b/test/files/neg/t3507.check @@ -1,4 +1,4 @@ -t3507.scala:13: error: No Manifest available for object _1.b.c. +t3507.scala:13: error: No Manifest available for _1.b.c.type. mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier ^ one error found |