[Bug]: Undefined function error thrown for Immutable object attached function call
Opened this issue · 0 comments
HindujaB commented
Description
$subject
Steps to Reproduce
Try out this sample.
public type File readonly & object {
public function filename() returns string;
};
public function format(File file) {
string line = file.filename();
}
public type Diagnostic record {|
Location location;
|};
public type Location readonly & record {|
File file;
|};
public readonly class VirtualFile {
*File;
public function filename() returns string => "Hello";
}
public function main() {
File file = new VirtualFile();
format(file);
}
This fails with the compilation error
undefined method 'filename' in object 'hinduja/test_project:0.1.0:(hinduja/test_project:0:$anonType$File$_0 & readonly)'
The error get resolved when we do one of the follwing things.
- Remove the
Diagnostic
record - Make the
Location
record non-readonly - Make the
File
object non-readonly
Affected Version(s)
2201.10.0-SNAPSHOT
OS, DB, other environment details and versions
No response
Related area
-> Compilation
Related issue(s) (optional)
No response
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response