Skip to content

Commit 615c440

Browse files
committed
Fix type inference of map properties
1 parent 9796e18 commit 615c440

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

src/main/java/nextflow/script/control/TypeCheckingVisitorEx.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,9 +1179,11 @@ public void visitPropertyExpression(PropertyExpression node) {
11791179
return;
11801180
}
11811181

1182-
var type = getType(node);
1183-
if( !ClassHelper.isDynamicTyped(type) )
1182+
var target = resolveProperty(node);
1183+
if( target != null ) {
1184+
node.putNodeMetaData(ASTNodeMarker.INFERRED_TYPE, target.getType());
11841185
return;
1186+
}
11851187

11861188
var mn = asMethodNamedOutput(node);
11871189
var property = node.getPropertyAsString();

src/test/groovy/nextflow/script/types/TypeCheckingTest.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,20 @@ class TypeCheckingTest extends Specification {
447447
'workflow.outputDir.name' | null
448448
}
449449

450+
def 'should check a map property' () {
451+
when:
452+
def exp = parseExpression(
453+
'''
454+
workflow {
455+
def meta: Map = [:]
456+
meta.id
457+
}
458+
'''
459+
)
460+
then:
461+
checkType(exp, Object)
462+
}
463+
450464
def 'should check a workflow call' () {
451465
expect:
452466
check(

src/test/groovy/nextflow/script/types/TypeCheckingUtilsTest.groovy

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,6 @@ class TypeCheckingUtilsTest extends Specification {
110110
'workflow.projectDir.name' | String
111111
}
112112

113-
def 'should resolve the type of a map property' () {
114-
when:
115-
def exp = parseExpression(
116-
'''
117-
workflow {
118-
def meta: Map = [:]
119-
meta.id
120-
}
121-
'''
122-
)
123-
then:
124-
checkType(exp, Object)
125-
}
126-
127113
@Unroll
128114
def 'should resolve the return type of a method call' () {
129115
expect:

0 commit comments

Comments
 (0)