Skip to content

Commit 02a8b70

Browse files
committed
Address review comments
1 parent bc07b03 commit 02a8b70

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import printing.Printer
1111
import printing.Texts.Text
1212
import util.{Stats, Attachment, Property, SourceFile, NoSource, SrcPos, SourcePosition}
1313
import config.Config
14+
import config.Printers.overload
1415
import annotation.internal.sharable
1516
import annotation.unchecked.uncheckedVariance
1617
import annotation.constructorOnly
@@ -1729,7 +1730,9 @@ object Trees {
17291730
val typer = ctx.typer
17301731
val proto = FunProto(args, expectedType)
17311732
val denot = receiver.tpe.member(method)
1732-
assert(denot.exists, i"no member $receiver . $method, members = ${receiver.tpe.decls}")
1733+
if !denot.exists then
1734+
overload.println(i"members = ${receiver.tpe.decls}")
1735+
report.error(i"no member $receiver . $method", receiver.srcPos)
17331736
val selected =
17341737
if (denot.isOverloaded) {
17351738
def typeParamCount(tp: Type) = tp.widen match {

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import core._
77
import dotty.tools.dotc.typer.Checking
88
import dotty.tools.dotc.typer.Inliner
99
import dotty.tools.dotc.typer.VarianceChecker
10+
import typer.ErrorReporting.errorTree
1011
import Types._, Contexts._, Names._, Flags._, DenotTransformers._, Phases._
1112
import SymDenotations._, StdNames._, Annotations._, Trees._, Scopes._
1213
import Decorators._
@@ -263,9 +264,9 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
263264
case Select(qual, _) => check(qual) // simple select _n
264265
case Apply(TypeApply(Select(qual, _), _), _) => check(qual) // generic select .apply[T](n)
265266

266-
def checkNotPackage(tree: Tree)(using Context): Unit =
267-
if tree.symbol.is(Package) then
268-
report.error(i"${tree.symbol} cannot be used as a type", tree.srcPos)
267+
def checkNotPackage(tree: Tree)(using Context): Tree =
268+
if !tree.symbol.is(Package) then tree
269+
else errorTree(tree, i"${tree.symbol} cannot be used as a type")
269270

270271
override def transform(tree: Tree)(using Context): Tree =
271272
try tree match {
@@ -280,7 +281,6 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
280281
case tree: Ident =>
281282
if tree.isType then
282283
checkNotPackage(tree)
283-
tree
284284
else
285285
if tree.symbol.is(Inline) && !Inliner.inInlineMethod then
286286
ctx.compilationUnit.needsInlining = true
@@ -293,9 +293,8 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
293293
if tree.symbol.is(Inline) then
294294
ctx.compilationUnit.needsInlining = true
295295
if name.isTypeName then
296-
checkNotPackage(tree)
297296
Checking.checkRealizable(qual.tpe, qual.srcPos)
298-
withMode(Mode.Type)(super.transform(tree))
297+
withMode(Mode.Type)(super.transform(checkNotPackage(tree)))
299298
else
300299
checkNoConstructorProxy(tree)
301300
transformSelect(tree, Nil)

compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
262262
// compare primitive fields first, slow equality checks of non-primitive fields can be skipped when primitives differ
263263
val sortedAccessors = accessors.sortBy(accessor => if (accessor.info.typeSymbol.isPrimitiveValueClass) 0 else 1)
264264
val comparisons = sortedAccessors.map { accessor =>
265-
This(clazz).select(accessor).equal(ref(thatAsClazz).select(accessor)) }
265+
This(clazz).withSpan(ctx.owner.span.focus).select(accessor).equal(ref(thatAsClazz).select(accessor)) }
266266
var rhs = // this.x == this$0.x && this.y == x$0.y && that.canEqual(this)
267267
if comparisons.isEmpty then Literal(Constant(true)) else comparisons.reduceLeft(_ and _)
268268
val canEqualMeth = existingDef(defn.Product_canEqual, clazz)

tests/neg/i12432.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package dotty.tools.dotc.typer
21

3-
class i1 ( i1 : annotation ) // error
4-
class i2 ( a : scala.annotation ) // error
2+
case class i1 ( i1 : annotation ) // error // error
3+
class i2 ( a : scala.annotation ) // error
4+

0 commit comments

Comments
 (0)