Skip to content

Wrong manipulation of byte constants #24321

@hamzaremmal

Description

@hamzaremmal

Compiler version

3.7.3

Minimized code

class Foo {
    public static final byte MAX = 10;
}
object Bar:
  final val MAX: Byte = 10

val x = Foo.MAX to Foo.MAX
val y = Bar.MAX to Bar.MAX

Output

-- [E008] Not Found Error: test.scala:5:16 -------------------------------------
5 |val y = Bar.MAX to Bar.MAX
  |        ^^^^^^^^^^
  |        value to is not a member of Byte.
  |        An extension method was tried, but could not be fully constructed:
  |
  |            intWrapper(Bar.MAX)

Expectation

Both should fail because there is no to method available for Byte. The first one works because it gets converted to an Int.

package <empty> {
  final lazy module val Bar: Bar = new Bar()
  final module class Bar() extends Object() { this: Bar.type =>
    final val MAX: Byte = 10
  }
  final lazy module val test$package: test$package = new test$package()
  final module class test$package() extends Object() {
    this: test$package.type =>
    val x: scala.collection.immutable.Range.Inclusive = intWrapper(10).to(10)
    val y:
      
        <error value to is not a member of Byte.
An extension method was tried, but could not be fully constructed:

    intWrapper(Bar.MAX)>
        
     = Bar.MAX.to(Bar.MAX)
  }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions