@@ -255,6 +255,10 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
255
255
if tree.symbol.is(ConstructorProxy ) then
256
256
report.error(em " constructor proxy ${tree.symbol} cannot be used as a value " , tree.srcPos)
257
257
258
+ def checkNotPackage (tree : Tree )(using Context ): Unit =
259
+ if tree.symbol.is(Package ) then
260
+ report.error(i " ${tree.symbol} cannot be used as a type " , tree.srcPos)
261
+
258
262
override def transform (tree : Tree )(using Context ): Tree =
259
263
try tree match {
260
264
// TODO move CaseDef case lower: keep most probable trees first for performance
@@ -265,21 +269,25 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
265
269
case None =>
266
270
ctx
267
271
super .transform(tree)(using gadtCtx)
268
- case tree : Ident if ! tree.isType =>
269
- if tree.symbol.is(Inline ) && ! Inliner .inInlineMethod then
270
- ctx.compilationUnit.needsInlining = true
271
- checkNoConstructorProxy(tree)
272
- tree.tpe match {
273
- case tpe : ThisType => This (tpe.cls).withSpan(tree.span)
274
- case _ => tree
275
- }
272
+ case tree : Ident =>
273
+ if tree.isType then
274
+ checkNotPackage(tree)
275
+ tree
276
+ else
277
+ if tree.symbol.is(Inline ) && ! Inliner .inInlineMethod then
278
+ ctx.compilationUnit.needsInlining = true
279
+ checkNoConstructorProxy(tree)
280
+ tree.tpe match {
281
+ case tpe : ThisType => This (tpe.cls).withSpan(tree.span)
282
+ case _ => tree
283
+ }
276
284
case tree @ Select (qual, name) =>
277
285
if tree.symbol.is(Inline ) then
278
286
ctx.compilationUnit.needsInlining = true
279
- if (name.isTypeName) {
287
+ if name.isTypeName then
288
+ checkNotPackage(tree)
280
289
Checking .checkRealizable(qual.tpe, qual.srcPos)
281
290
withMode(Mode .Type )(super .transform(tree))
282
- }
283
291
else
284
292
checkNoConstructorProxy(tree)
285
293
transformSelect(tree, Nil )
0 commit comments