diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 5 | ||||
-rw-r--r-- | test/files/neg/bug1392.check | 4 | ||||
-rw-r--r-- | test/files/neg/bug1392.scala | 1 |
3 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 9518f62c37..427a299d51 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -572,13 +572,16 @@ trait Typers { self: Analyzer => * </ol> */ private def stabilize(tree: Tree, pre: Type, mode: Int, pt: Type): Tree = { + def isNotAValue(sym: Symbol) = // bug #1392 + !sym.isValue || (sym.isModule && isValueClass(sym.linkedClassOfModule)) + if (tree.symbol.hasFlag(OVERLOADED) && (mode & FUNmode) == 0) inferExprAlternative(tree, pt) val sym = tree.symbol if (tree.tpe.isError) tree else if ((mode & (PATTERNmode | FUNmode)) == PATTERNmode && tree.isTerm) { // (1) checkStable(tree) - } else if ((mode & (EXPRmode | QUALmode)) == EXPRmode && !sym.isValue && !phase.erasedTypes) { // (2) + } else if ((mode & (EXPRmode | QUALmode)) == EXPRmode && isNotAValue(sym) && !phase.erasedTypes) { // (2) errorTree(tree, sym+" is not a value") } else { if (sym.isStable && pre.isStable && tree.tpe.typeSymbol != ByNameParamClass && diff --git a/test/files/neg/bug1392.check b/test/files/neg/bug1392.check new file mode 100644 index 0000000000..e4c9630435 --- /dev/null +++ b/test/files/neg/bug1392.check @@ -0,0 +1,4 @@ +bug1392.scala:1: error: object Int is not a value +object X extends Application { Int } + ^ +one error found diff --git a/test/files/neg/bug1392.scala b/test/files/neg/bug1392.scala new file mode 100644 index 0000000000..bb23818038 --- /dev/null +++ b/test/files/neg/bug1392.scala @@ -0,0 +1 @@ +object X extends Application { Int }
\ No newline at end of file |