File tree Expand file tree Collapse file tree 3 files changed +24
-4
lines changed
src/compiler/scala/tools/nsc/typechecker Expand file tree Collapse file tree 3 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -4881,10 +4881,11 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
4881
4881
(// this -> Foo.this
4882
4882
if (sym.isThisSym)
4883
4883
typed1(This (sym.owner) setPos tree.pos, mode, pt)
4884
- // Inferring classOf type parameter from expected type. Otherwise an
4885
- // actual call to the stubbed classOf method is generated, returning null.
4886
- else if (isPredefClassOf(sym) && pt.typeSymbol == ClassClass && pt.typeArgs.nonEmpty)
4887
- typedClassOf(tree, TypeTree (pt.typeArgs.head))
4884
+ else if (isPredefClassOf(sym) && pt.typeSymbol == ClassClass && pt.typeArgs.nonEmpty) {
4885
+ // Inferring classOf type parameter from expected type. Otherwise an
4886
+ // actual call to the stubbed classOf method is generated, returning null.
4887
+ typedClassOf(tree, TypeTree (pt.typeArgs.head).setPos(tree.pos.focus))
4888
+ }
4888
4889
else {
4889
4890
val pre1 = if (sym.isTopLevel) sym.owner.thisType else if (qual == EmptyTree ) NoPrefix else qual.tpe
4890
4891
val tree1 = if (qual == EmptyTree ) tree else atPos(tree.pos)(Select (atPos(tree.pos.focusStart)(qual), name))
Original file line number Diff line number Diff line change
1
+ t9273.scala:2: error: class type required but ? found
2
+ val foo: Class[_] = classOf // error without position, line or file
3
+ ^
4
+ t9273.scala:3: error: not found: type X
5
+ val foo1: Class[_] = classOf[X] // good error, all info contained
6
+ ^
7
+ t9273.scala:7: error: not found: type X
8
+ val foo4: Class[_] = Predef.classOf[X] // good error, all info contained
9
+ ^
10
+ three errors found
Original file line number Diff line number Diff line change
1
+ class MissingLineNumbers {
2
+ val foo : Class [_] = classOf // error without position, line or file
3
+ val foo1 : Class [_] = classOf [X ] // good error, all info contained
4
+ val foo2 = classOf // Infers T=Nothing
5
+
6
+ val foo3 : Class [_] = Predef .classOf // Infers T=Nothing. Irregular wrt typedIdent.
7
+ val foo4 : Class [_] = Predef .classOf [X ] // good error, all info contained
8
+ val foo5 = Predef .classOf // Infers T=Nothing
9
+ }
You can’t perform that action at this time.
0 commit comments