Skip to content

Commit f3d5201

Browse files
committed
Address review comments
1 parent eaa28f3 commit f3d5201

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
@@ -12,6 +12,7 @@ import printing.Printer
1212
import printing.Texts.Text
1313
import util.{Stats, Attachment, Property, SourceFile, NoSource, SrcPos, SourcePosition}
1414
import config.Config
15+
import config.Printers.overload
1516
import annotation.internal.sharable
1617
import annotation.unchecked.uncheckedVariance
1718
import annotation.constructorOnly
@@ -1672,7 +1673,9 @@ object Trees {
16721673
val typer = ctx.typer
16731674
val proto = FunProto(args, expectedType)
16741675
val denot = receiver.tpe.member(method)
1675-
assert(denot.exists, i"no member $receiver . $method, members = ${receiver.tpe.decls}")
1676+
if !denot.exists then
1677+
overload.println(i"members = ${receiver.tpe.decls}")
1678+
report.error(i"no member $receiver . $method", receiver.srcPos)
16761679
val selected =
16771680
if (denot.isOverloaded) {
16781681
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._
@@ -253,9 +254,9 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
253254
if tree.symbol.is(ConstructorProxy) then
254255
report.error(em"constructor proxy ${tree.symbol} cannot be used as a value", tree.srcPos)
255256

256-
def checkNotPackage(tree: Tree)(using Context): Unit =
257-
if tree.symbol.is(Package) then
258-
report.error(i"${tree.symbol} cannot be used as a type", tree.srcPos)
257+
def checkNotPackage(tree: Tree)(using Context): Tree =
258+
if !tree.symbol.is(Package) then tree
259+
else errorTree(tree, i"${tree.symbol} cannot be used as a type")
259260

260261
override def transform(tree: Tree)(using Context): Tree =
261262
try tree match {
@@ -270,7 +271,6 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
270271
case tree: Ident =>
271272
if tree.isType then
272273
checkNotPackage(tree)
273-
tree
274274
else
275275
if tree.symbol.is(Inline) && !Inliner.inInlineMethod then
276276
ctx.compilationUnit.needsInlining = true
@@ -283,9 +283,8 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
283283
if tree.symbol.is(Inline) then
284284
ctx.compilationUnit.needsInlining = true
285285
if name.isTypeName then
286-
checkNotPackage(tree)
287286
Checking.checkRealizable(qual.tpe, qual.srcPos)
288-
withMode(Mode.Type)(super.transform(tree))
287+
withMode(Mode.Type)(super.transform(checkNotPackage(tree)))
289288
else
290289
checkNoConstructorProxy(tree)
291290
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
@@ -252,7 +252,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
252252
// compare primitive fields first, slow equality checks of non-primitive fields can be skipped when primitives differ
253253
val sortedAccessors = accessors.sortBy(accessor => if (accessor.info.typeSymbol.isPrimitiveValueClass) 0 else 1)
254254
val comparisons = sortedAccessors.map { accessor =>
255-
This(clazz).select(accessor).equal(ref(thatAsClazz).select(accessor)) }
255+
This(clazz).withSpan(ctx.owner.span.focus).select(accessor).equal(ref(thatAsClazz).select(accessor)) }
256256
var rhs = // this.x == this$0.x && this.y == x$0.y && that.canEqual(this)
257257
if comparisons.isEmpty then Literal(Constant(true)) else comparisons.reduceLeft(_ and _)
258258
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)