Repository: apple/pkl
File: pkl-core/src/main/java/org/pkl/core/ast/member/PropertyTypeNode.java (Java)

Code before:
  }

  @Override
  public String getName() {
    return qualifiedPropertyName;
  }

  private boolean isInIterable(VirtualFrame frame) {
    if (frame.getArguments().length < 4) {
      return false;
    }
    if (frame.getArguments()[3] instanceof Boolean isInIterable) {
      return isInIterable;
    }
    return false;
  }

  @Override
  public Object execute(VirtualFrame frame) {
    try {
      if (isInIterable(frame)) {
        // There is currently a bug around resolving variables within the iterable of a for
        // generator or spread syntax (https://github.com/apple/pkl/issues/741)
        //
        // Normally, mappings/listings are type-checked lazily. However, this results in the said
        // bug getting widened, for any object members declared in the iterable.
        //
        // As a workaround for now, prevent the bug from being any worse by ensuring that these
        // object members are eagerly typechecked.
        return typeNode.executeEagerly(frame, frame.getArguments()[2]);
      }
      return typeNode.execute(frame, frame.getArguments()[2]);
    } catch (VmTypeMismatchException e) {
      CompilerDirectives.transferToInterpreter();
      throw e.toVmException();
    } catch (Exception e) {
      CompilerDirectives.transferToInterpreter();
      if (e instanceof VmException) {
        throw e;
      } else {
        throw exceptionBuilder().bug(e.getMessage()).withCause(e).build();
      }
    }
  }

  public @Nullable Object getDefaultValue() {
    if (!defaultValueInitialized) {
      defaultValue =
          typeNode.createDefaultValue(
              VmLanguage.get(this), getSourceSection(), qualifiedPropertyName);
      defaultValueInitialized = true;

Review comment (bug):
```suggestion
        // Normally, mappings/listings are type-checked lazily. However, this results in said
        // bug getting widened, for any object members declared in the iterable.
```
^^ Only still used in British English, esp. legalese;

> **The said.** As used in legal writing, the word said is a Middle-English sibling aforesaid, having the sense "above-stated." Originally legal writers would write _the said defendant_ － and still do in BrE － just as they would write _the aforesaid defendant_ or _the above-stated defendant_. In AmE, however, _the_ was dropped before _said_, which has come to act almost as an article.

 -- A Dictionary of Modern Legal Usage, 2nd edition, Bryan A. Garner

Code after:
  }

  @Override
  public String getName() {
    return qualifiedPropertyName;
  }

  private boolean isInIterable(VirtualFrame frame) {
    var args = frame.getArguments();
    return args.length >= 4 && args[3] instanceof Boolean b && b;
  }

  @Override
  public Object execute(VirtualFrame frame) {
    try {
      if (isInIterable(frame)) {
        // There is currently a bug around resolving variables within the iterable of a for
        // generator or spread syntax (https://github.com/apple/pkl/issues/741)
        //
        // Normally, mappings/listings are type-checked lazily. However, this results in said
        // bug getting widened, for any object members declared in the iterable.
        //
        // As a workaround for now, prevent the bug from being any worse by ensuring that these
        // object members are eagerly typechecked.
        return typeNode.executeEagerly(frame, frame.getArguments()[2]);
      }
      return typeNode.execute(frame, frame.getArguments()[2]);
    } catch (VmTypeMismatchException e) {
      CompilerDirectives.transferToInterpreter();
      throw e.toVmException();
    } catch (Exception e) {
      CompilerDirectives.transferToInterpreter();
      if (e instanceof VmException) {
        throw e;
      } else {
        throw exceptionBuilder().bug(e.getMessage()).withCause(e).build();
      }
    }
  }

  public @Nullable Object getDefaultValue() {
    if (!defaultValueInitialized) {
      defaultValue =
          typeNode.createDefaultValue(
              VmLanguage.get(this), getSourceSection(), qualifiedPropertyName);
      defaultValueInitialized = true;
    }
    return defaultValue;
  }

  public boolean isUnknownType() {