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