ronantakizawa/codereview-bench huggingface dataset:
Repository: apache/hadoop
File: hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeReconfigure.java (Java)

Code before:
  }

  @Test
  public void testReconfigureMaxDirItems() throws ReconfigurationException {
    final NameNode nameNode = cluster.getNameNode();
    final FSDirectory fsd = nameNode.namesystem.getFSDirectory();

    // By default, DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY is 1024 * 1024.
    assertEquals(1024 * 1024, fsd.getMaxDirItems());

    // Reconfigure.
    nameNode.reconfigureProperty(DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY,
        Integer.toString(1024 * 1024 * 2));

    // Assert DFS_NAMENODE_MAX_SLOWPEER_COLLECT_NODES_KEY is 1024 * 1024 * 2.
    assertEquals(1024 * 1024 * 2, fsd.getMaxDirItems());

    try {
      // Reconfigure to negative, and expect failed.
      nameNode.reconfigureProperty(DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY,
          Integer.toString(1024 * 1024 * -1));
    } catch (ReconfigurationException e) {
      assertEquals("Could not change property " +
          "dfs.namenode.fs-limits.max-directory-items from '" + 1024 * 1024 * 2
          + "' to '" + 1024 * 1024 * -1 + "'", e.getMessage());
    }

    // Assert DFS_NAMENODE_MAX_SLOWPEER_COLLECT_NODES_KEY is also 1024 * 1024 * 2.
    assertEquals(1024 * 1024 * 2, fsd.getMaxDirItems());
  }

  @AfterEach
  public void shutDown() throws IOException {
    if (cluster != null) {
      cluster.shutdown();
    }
  }
}

Review comment (suggestion):
use LamdaTestUtils
```

    LambdaTestUtils.intercept(ReconfigurationException.class,
        "Could not change property dfs.namenode.fs-limits.max-directory-items from '" + 1024 * 1024 * 2 + "' to '"
            + 1024 * 1024 * -1 + "'",
        () -> nameNode.reconfigureProperty(DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY, Integer.toString(1024 * 1024 * -1)));
```

Code after:
  }

  @Test
  public void testReconfigureMaxDirItems() throws Exception {
    final NameNode nameNode = cluster.getNameNode();
    final FSDirectory fsd = nameNode.namesystem.getFSDirectory();

    // By default, DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY is 1024 * 1024.
    assertEquals(1024 * 1024, fsd.getMaxDirItems());

    // Reconfigure.
    nameNode.reconfigureProperty(DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY,
        Integer.toString(1024 * 1024 * 2));

    // Assert DFS_NAMENODE_MAX_SLOWPEER_COLLECT_NODES_KEY is 1024 * 1024 * 2.
    assertEquals(1024 * 1024 * 2, fsd.getMaxDirItems());

    // Reconfigure to negative, and expect failed.
    LambdaTestUtils.intercept(ReconfigurationException.class,
        "Could not change property dfs.namenode.fs-limits.max-directory-items from '"
            + 1024 * 1024 * 2 + "' to '" + 1024 * 1024 * -1 + "'",
        () -> nameNode.reconfigureProperty(DFS_NAMENODE_MAX_DIRECTORY_ITEMS_KEY,
            Integer.toString(1024 * 1024 * -1)));

    // Assert DFS_NAMENODE_MAX_SLOWPEER_COLLECT_NODES_KEY is also 1024 * 1024 * 2.
    assertEquals(1024 * 1024 * 2, fsd.getMaxDirItems());
  }

  @AfterEach
  public void shutDown() throws IOException {
    if (cluster != null) {
      cluster.shutdown();
    }
  }
}
Repository: apache/hadoop
File: start-build-env.sh (Shell)

Code before:
fi

# Set the home directory in the Docker container.
DOCKER_HOME_DIR=${DOCKER_HOME_DIR:-/home/${USER_NAME}}

docker build "${DOCKER_PLATFORM_ARGS[@]}" -t "hadoop-build${OS_PLATFORM_SUFFIX}-${USER_ID}" - <<UserSpecificDocker
FROM hadoop-build
RUN rm -f /var/log/faillog /var/log/lastlog
RUN userdel -r \$(getent passwd ${USER_ID} | cut -d: -f1) 2>/dev/null || :
RUN groupadd --non-unique -g ${GROUP_ID} ${USER_NAME}
RUN useradd -g ${GROUP_ID} -u ${USER_ID} -k /root -m ${USER_NAME} -d "${DOCKER_HOME_DIR}"
RUN echo "${USER_NAME} ALL=NOPASSWD: ALL" > "/etc/sudoers.d/hadoop-build-${USER_ID}"
ENV HOME="${DOCKER_HOME_DIR}"

UserSpecificDocker

# If this env variable is empty, docker will be started
# in non interactive mode
DOCKER_INTERACTIVE_RUN=${DOCKER_INTERACTIVE_RUN-"-i -t"}

# By mapping the .m2 directory you can do an mvn install from
# within the container and use the result on your normal
# system.  And this also is a significant speedup in subsequent
# builds because the dependencies are downloaded only once.
docker run "${DOCKER_PLATFORM_ARGS[@]}" --rm=true ${DOCKER_INTERACTIVE_RUN} \
  -v "${PWD}:${DOCKER_HOME_DIR}/hadoop${V_OPTS:-}" \
  -w "${DOCKER_HOME_DIR}/hadoop" \
  -v "${HOME}/.m2:${DOCKER_HOME_DIR}/.m2${V_OPTS:-}" \
  -v "${HOME}/.gnupg:${DOCKER_HOME_DIR}/.gnupg${V_OPTS:-}" \
  -u "${USER_ID}" \
  --name "hadoop-build${OS_PLATFORM_SUFFIX}" \
  "hadoop-build${OS_PLATFORM_SUFFIX}-${USER_ID}" "$@"


Review comment (suggestion):
Would you mind putting quotes around `"${DOCKER_INTERACTIVE_RUN}"`? That will give us a completely clean shellcheck on this file.

Code after:
fi

# Set the home directory in the Docker container.
DOCKER_HOME_DIR=${DOCKER_HOME_DIR:-/home/${USER_NAME}}

docker build "${DOCKER_PLATFORM_ARGS[@]}" -t "hadoop-build${OS_PLATFORM_SUFFIX}-${USER_ID}" - <<UserSpecificDocker
FROM hadoop-build
RUN rm -f /var/log/faillog /var/log/lastlog
RUN userdel -r \$(getent passwd ${USER_ID} | cut -d: -f1) 2>/dev/null || :
RUN groupadd --non-unique -g ${GROUP_ID} ${USER_NAME}
RUN useradd -g ${GROUP_ID} -u ${USER_ID} -k /root -m ${USER_NAME} -d "${DOCKER_HOME_DIR}"
RUN echo "${USER_NAME} ALL=NOPASSWD: ALL" > "/etc/sudoers.d/hadoop-build-${USER_ID}"
ENV HOME="${DOCKER_HOME_DIR}"

UserSpecificDocker

# If this env variable is empty, docker will be started
# in non interactive mode
DOCKER_INTERACTIVE_RUN=${DOCKER_INTERACTIVE_RUN-"-i -t"}

# By mapping the .m2 directory you can do an mvn install from
# within the container and use the result on your normal
# system.  And this also is a significant speedup in subsequent
# builds because the dependencies are downloaded only once.
# shellcheck disable=SC2086
docker run "${DOCKER_PLATFORM_ARGS[@]}" --rm=true ${DOCKER_INTERACTIVE_RUN} \
  -v "${PWD}:${DOCKER_HOME_DIR}/hadoop${V_OPTS:-}" \
  -w "${DOCKER_HOME_DIR}/hadoop" \
  -v "${HOME}/.m2:${DOCKER_HOME_DIR}/.m2${V_OPTS:-}" \
  -v "${HOME}/.gnupg:${DOCKER_HOME_DIR}/.gnupg${V_OPTS:-}" \
  -u "${USER_ID}" \
  --name "hadoop-build${OS_PLATFORM_SUFFIX}" \
  "hadoop-build${OS_PLATFORM_SUFFIX}-${USER_ID}" "$@"
Repository: apexcharts/apexcharts.js
File: src/modules/Scales.js (JavaScript)

Code before:
    let step = range / ticks
    if (ticks === Number.MAX_VALUE) {
      ticks = 10
      step = 1
    }

    let result = []
    let v = yMin

    while (ticks >= 0) {
      result.push(v)
      v = v + step
      ticks -= 1
    }

    return {
      result,
      niceMin: result[0],
      niceMax: result[result.length - 1]
    }
  }

  logarithmicScale(yMax) {
    let logs = []

    let ticks = Math.ceil(Math.log10(yMax)) + 1; // Get powers of 10 up to our max, and then one more

    for(let i = 0; i < ticks; i++) {
      logs.push(Math.pow(10, i))
    }

    return {
      result: logs,
      niceMin: logs[0],
      niceMax: logs[logs.length - 1]
    }
  }

  setYScaleForIndex(index, minY, maxY) {
    const gl = this.w.globals
    const cnf = this.w.config

    let y = gl.isBarHorizontal ? cnf.xaxis : cnf.yaxis[index]

    if (typeof gl.yAxisScale[index] === 'undefined') {
      gl.yAxisScale[index] = []
    }

    let diff = Math.abs(maxY - minY)

    if (y.logarithmic && diff <= 5) {

Review comment (suggestion):
```suggestion
    const ticks = Math.ceil(Math.log10(yMax)) + 1; // Get powers of 10 up to our max, and then one more
```

Code after:

    ticks = this._adjustTicksForSmallRange(ticks, index, range)

    let step = range / ticks
    if (ticks === Number.MAX_VALUE) {
      ticks = 10
      step = 1
    }

    let result = []
    let v = yMin

    while (ticks >= 0) {
      result.push(v)
      v = v + step
      ticks -= 1
    }

    return {
      result,
      niceMin: result[0],
      niceMax: result[result.length - 1]
    }
  }

  logarithmicScale(yMax) {
    const logs = []

    const ticks = Math.ceil(Math.log10(yMax)) + 1; // Get powers of 10 up to our max, and then one more

    for(let i = 0; i < ticks; i++) {
      logs.push(Math.pow(10, i))
    }

    return {
      result: logs,
      niceMin: logs[0],
      niceMax: logs[logs.length - 1]
    }
  }

  _adjustTicksForSmallRange(ticks, index, range) {
    let newTicks = ticks
    if (
      typeof index !== 'undefined' &&
      this.w.config.yaxis[index].labels.formatter
    ) {
      const formattedVal = this.w.config.yaxis[index].labels.formatter(1)
      if (
        Utils.isNumber(Number(formattedVal)) &&
        !Utils.isFloat(formattedVal)
Repository: apexcharts/apexcharts.js
File: src/modules/TimeScale.js (JavaScript)

Code before:
        position: pos,
        value: val,
        unit,
        hour,
        day: date,
        year,
        month: Utils.monthMod(month)
      })

      hour++
    }
  }

  generateMinuteScale({
    currentSecond,
    currentMinute,
    currentHour,
    currentDate,
    currentMonth,
    currentYear,
    minutesWidthOnXAxis,
    secondsWidthOnXAxis,
    numberOfMinutes
  }) {
    let yrCounter = 0
    let unit = 'minute'

    let remainingSecs = 60 - currentSecond
    let firstTickPosition = remainingSecs * secondsWidthOnXAxis
    let minute = currentMinute + 1

    let date = currentDate
    let month = currentMonth
    let year = currentYear
    let hour = currentHour

    let pos = firstTickPosition
    // keep drawing rest of the ticks
    for (let i = 0; i < numberOfMinutes; i++) {
      if (minute >= 60) {
        minute = 0
        hour += 1
        if (hour === 24) {
          hour = 0
        }
      }

      this.timeScaleArray.push({
        position: pos,
        value: minute,
        unit,

Review comment (bug):
* For the first tick minute and value were different because of this incrementation.
* Also if first minute is 59, it was incorrectly added as `{ value: 60, minute: 61 }`

Resolved both of these problems by moving addition of the first tick inside a loop below.
Added unit test covering this.

Code after:
          : 60 * minutesWidthOnXAxis + pos
      let val = hour === 0 ? date : hour
      this.timeScaleArray.push({
        position: pos,
        value: val,
        unit,
        hour,
        day: date,
        year,
        month: Utils.monthMod(month)
      })

      hour++
    }
  }

  generateMinuteScale({
    currentMillisecond,
    currentSecond,
    currentMinute,
    currentHour,
    currentDate,
    currentMonth,
    currentYear,
    minutesWidthOnXAxis,
    secondsWidthOnXAxis,
    numberOfMinutes
  }) {
    let yrCounter = 0
    let unit = 'minute'

    let remainingSecs = 60 - currentSecond
    let firstTickPosition =
      (remainingSecs - currentMillisecond / 1000) * secondsWidthOnXAxis
    let minute = currentMinute + 1

    let date = currentDate
    let month = currentMonth
    let year = currentYear
    let hour = currentHour

    let pos = firstTickPosition
    for (let i = 0; i < numberOfMinutes; i++) {
      if (minute >= 60) {
        minute = 0
        hour += 1
        if (hour === 24) {
          hour = 0
        }
      }
Repository: apexcharts/apexcharts.js
File: src/modules/TimeScale.js (JavaScript)

Code before:
    currentSecond,
    currentMinute,
    currentHour,
    currentDate,
    currentMonth,
    currentYear,
    minutesWidthOnXAxis,
    secondsWidthOnXAxis,
    numberOfMinutes
  }) {
    let yrCounter = 0
    let unit = 'minute'

    let remainingSecs = 60 - firstVal.minSecond

    let firstTickPosition = remainingSecs * secondsWidthOnXAxis
    let firstTickValue = firstVal.minMinute + 1
    let minute = firstTickValue + 1

    let date = currentDate
    let month = currentMonth
    let year = currentYear
    let hour = currentHour

    // push the first tick in the array
    this.timeScaleArray.push({
      position: firstTickPosition,
      value: firstTickValue,
      unit,
      day: date,
      hour,
      minute,
      year,
      month: Utils.monthMod(month)
    })

    let pos = firstTickPosition
    // keep drawing rest of the ticks
    for (let i = 0; i < numberOfMinutes; i++) {
      if (minute >= 60) {
        minute = 0
        hour += 1
        if (hour === 24) {
          hour = 0
        }
      }

      pos = minutesWidthOnXAxis + pos
      this.timeScaleArray.push({
        position: pos,
        value: minute,

Review comment (suggestion):
On some close zoom levels label is positioned several pixels off comparing to tooltip line.
Accounted for milliseconds to fix that.
![image](https://user-images.githubusercontent.com/7345182/112870937-702fbb00-90c7-11eb-8779-6574748d75f0.png)

Code after:
        year,
        month: Utils.monthMod(month)
      })

      hour++
    }
  }

  generateMinuteScale({
    currentMillisecond,
    currentSecond,
    currentMinute,
    currentHour,
    currentDate,
    currentMonth,
    currentYear,
    minutesWidthOnXAxis,
    secondsWidthOnXAxis,
    numberOfMinutes
  }) {
    let yrCounter = 0
    let unit = 'minute'

    let remainingSecs = 60 - currentSecond
    let firstTickPosition =
      (remainingSecs - currentMillisecond / 1000) * secondsWidthOnXAxis
    let minute = currentMinute + 1

    let date = currentDate
    let month = currentMonth
    let year = currentYear
    let hour = currentHour

    let pos = firstTickPosition
    for (let i = 0; i < numberOfMinutes; i++) {
      if (minute >= 60) {
        minute = 0
        hour += 1
        if (hour === 24) {
          hour = 0
        }
      }

      this.timeScaleArray.push({
        position: pos,
        value: minute,
        unit,
        hour,
        minute,
        day: date,
        year: this._getYear(year, month, yrCounter),
Repository: apexcharts/apexcharts.js
File: src/modules/settings/Options.js (JavaScript)

Code before:
/**
 * ApexCharts Options for setting the initial configuration of ApexCharts
 **/
import en from './../../locales/en.json'

export default class Options {
  constructor() {
    this.yAxis = {
      show: true,
      showAlways: false,
      showForNullSeries: true,
      seriesName: undefined,
      opposite: false,
      reversed: false,
      logarithmic: {
        isActive: false,
        base: 10
      },
      tickAmount: undefined,
      forceNiceScale: false,
      max: undefined,
      min: undefined,
      floating: false,
      decimalsInFloat: undefined,
      labels: {
        show: true,
        minWidth: 0,
        maxWidth: 160,
        offsetX: 0,
        offsetY: 0,
        align: undefined,
        rotate: 0,
        padding: 20,
        style: {
          colors: [],
          fontSize: '11px',
          fontWeight: 400,
          fontFamily: undefined,
          cssClass: ''
        },

Review comment (suggestion):
The modified property is a significant change in the API and will break the log scale for all the people who use the old versions.
I propose another way to introduce this new feature. Instead of converting the logarithmic property from `boolean` to `object`, let's keep it is as, and add a new property logBase.

So, it becomes like this

```js
logarithmic: false,
logBase: 10
```

This way, we don't introduce a breaking change.

Code after:
/**
 * ApexCharts Options for setting the initial configuration of ApexCharts
 **/
import en from './../../locales/en.json'

export default class Options {
  constructor() {
    this.yAxis = {
      show: true,
      showAlways: false,
      showForNullSeries: true,
      seriesName: undefined,
      opposite: false,
      reversed: false,
      logarithmic: false,
      logBase: 10,
      tickAmount: undefined,
      forceNiceScale: false,
      max: undefined,
      min: undefined,
      floating: false,
      decimalsInFloat: undefined,
      labels: {
        show: true,
        minWidth: 0,
        maxWidth: 160,
        offsetX: 0,
        offsetY: 0,
        align: undefined,
        rotate: 0,
        padding: 20,
        style: {
          colors: [],
          fontSize: '11px',
          fontWeight: 400,
          fontFamily: undefined,
          cssClass: ''
        },
        formatter: undefined
      },
Repository: apexcharts/apexcharts.js
File: src/modules/CoreUtils.js (JavaScript)

Code before:
/*
 ** Util functions which are dependent on ApexCharts instance
 */

class CoreUtils {
  constructor(ctx) {
    this.ctx = ctx
    this.w = ctx.w
  }

  static checkComboSeries(series, chartType) {
    let comboCharts = false
    let comboBarCount = 0
    let comboCount = 0
    
    if (chartType === 'undefined') {
      chartType = 'line'
    }
    
    // Check if user specified a type in series that may make us a combo chart.
    // The default type for chart is "line" and the default for series is the
    // chart type, therefore, if the types of all series match the chart type,
    // this should not be considered a combo chart.
    if (series.length && typeof series[0].type !== 'undefined') {
      series.forEach((s) => {
        if (
          s.type === 'bar' ||
          s.type === 'column' ||
          s.type === 'candlestick' ||
          s.type === 'boxPlot'
        ) {
          comboBarCount++
        }
        if (typeof s.type !== 'undefined' && s.type !== chartType) {
          comboCount++
        }
      })
    }
    if (comboCount > 0) {
      comboCharts = true
    }

Review comment (suggestion):
undefined as a string should be checked as `typeof chartType === 'undefined'`

Code after:
/*
 ** Util functions which are dependent on ApexCharts instance
 */

class CoreUtils {
  constructor(ctx) {
    this.ctx = ctx
    this.w = ctx.w
  }

  static checkComboSeries(series, chartType) {
    let comboCharts = false
    let comboBarCount = 0
    let comboCount = 0
    
    if (chartType === undefined) {
      chartType = 'line'
    }
    
    // Check if user specified a type in series that may make us a combo chart.
    // The default type for chart is "line" and the default for series is the
    // chart type, therefore, if the types of all series match the chart type,
    // this should not be considered a combo chart.
    if (series.length && typeof series[0].type !== 'undefined') {
      series.forEach((s) => {
        if (
          s.type === 'bar' ||
          s.type === 'column' ||
          s.type === 'candlestick' ||
          s.type === 'boxPlot'
        ) {
          comboBarCount++
        }
        if (typeof s.type !== 'undefined' && s.type !== chartType) {
          comboCount++
        }
      })
    }
    if (comboCount > 0) {
      comboCharts = true
    }
Repository: apple/swift
File: test/embedded/debug-precondition-condfail.swift (Swift)

Code before:
// RUN: %target-swift-frontend -g -emit-sil %s -enable-experimental-feature Embedded -module-name trap -wmo -o - | %FileCheck %s

// REQUIRES: swift_in_compiler
// REQUIRES: swift_feature_Embedded
// REQUIRES: CPU=x86_64 || CPU=arm64 || CPU=arm64e

// CHECK-LABEL: sil @$e4trap11rebindCheck3ptr8capacityySpySuG_SitFySpys5Int64VGXEfU_
public func rebindCheck(ptr: UnsafeMutablePointer<UInt>, capacity: Int) {
  // CHECK-NOT: _assertionFa
  // CHECK: cond_fail
  // CHECK-NOT: _assertionFa
  // CHECK: return
  ptr.withMemoryRebound(to: Int64.self, capacity: capacity) {
    $0.pointee.negate()
  }
}


Review comment (suggestion):
As a sanity check it might be good to add a second RUN line with `-emit-ir` that CHECKs for the existence of a `!DISubprogram` with the error message.

Code after:
// RUN: %target-swift-frontend -g -emit-sil %s -enable-experimental-feature Embedded -module-name trap -wmo -o - | %FileCheck %s

// RUN: %target-swift-frontend -g -emit-ir %s -enable-experimental-feature Embedded -module-name trap -wmo -o - | %FileCheck -check-prefix IR %s

// REQUIRES: swift_in_compiler
// REQUIRES: swift_feature_Embedded
// REQUIRES: CPU=x86_64 || CPU=arm64 || CPU=arm64e

// CHECK-LABEL: sil @$e4trap11rebindCheck3ptr8capacityySpySuG_SitFySpys5Int64VGXEfU_
public func rebindCheck(ptr: UnsafeMutablePointer<UInt>, capacity: Int) {
  // CHECK-NOT: _assertionFa
  // CHECK: cond_fail
  // CHECK-NOT: _assertionFa
  // CHECK: return
  ptr.withMemoryRebound(to: Int64.self, capacity: capacity) {
    $0.pointee.negate()
  }
}

// IR: distinct !DISubprogram(name: "Swift runtime failure: arithmetic overflow"
Repository: apple/swift
File: test/stdlib/KVOKeyPaths.swift (Swift)

Code before:
// RUN: %empty-directory(%t)
// RUN: %target-build-swift %s -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out | %FileCheck --check-prefixes=CHECK,CHECK-51,DONT-CHECK %s
// REQUIRES: executable_test

// REQUIRES: objc_interop

// FIXME: https://github.com/apple/swift/issues/52252
// Disable because it blocks PR testing.
// UNSUPPORTED: CPU=i386

import Foundation

struct Guts {
    var internalValue = 42
    var value: Int {
        get {
            return internalValue
        }
    }
    init(value: Int) {
        internalValue = value
    }
    init() {
    }
}

class Target : NSObject, NSKeyValueObservingCustomization {

Review comment (bug):
CHECK-51 is only expected to find matches when run against Swift 5.1 and later, so we still need to conditionalise that. I think we can do that using something like this however:
```
// RUN: export CHECK_PREFIX=%target-run %t/a.out | grep 'check-prefix'
// RUN: %target-run %t/a.out | %FileCheck -check-prefix=CHECK $CHECK_PREFIX %s
```

It also looks to me like we don't actually need the DONT-CHECK prefix, since we always use the CHECK prefix, so that can _probably_ be removed. I could be wrong on that point though.

Code after:
// RUN: %empty-directory(%t)
// RUN: %target-build-swift %s -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out > %t/output.txt
// RUN: %FileCheck %s < %t/output.txt
// RUN: grep "check-prefix=CHECK-51" %t/output.txt && %FileCheck %s --check-prefix=CHECK-51 < %t/output.txt
// REQUIRES: executable_test

// REQUIRES: objc_interop

import Foundation

struct Guts {
    var internalValue = 42
    var value: Int {
        get {
            return internalValue
        }
    }
    init(value: Int) {
        internalValue = value
    }
    init() {
    }
}

class Target : NSObject, NSKeyValueObservingCustomization {
    // This dynamic property is observed by KVO
    @objc dynamic var objcValue: String
Repository: apple/swift
File: validation-test/Sema/SwiftUI/rdar84580119.swift (Swift)

Code before:
// RUN: %target-typecheck-verify-swift -verify-ignore-unrelated -target %target-cpu-apple-macosx10.15 -swift-version 5
// REQUIRES: objc_interop
// REQUIRES: OS=macosx

import SwiftUI

extension HorizontalAlignment {
  private enum MyHorizontalAlignment: AlignmentID {
    static func defaultValue(in d: ViewDimensions) -> CGFloat { d.width }
  }
}

extension EnvironmentValues {
  var myHorizontalAlignment: AlignmentID? {
    get { fatalError() }
    set { self[\.MyHorizontalAlignmentEnvironmentKey.self] = newValue }
    // FIXME: error lost {{subscript 'subscript(_:)' requires that 'any AlignmentID' be a class type}}
    // expected-error@-2 {{value of type 'EnvironmentValues' has no member 'MyHorizontalAlignmentEnvironmentKey'}}
    // expected-error@-3 {{missing argument label 'keyPath:' in subscript}}
  }
}

struct MyHorizontalAlignmentEnvironmentKey: EnvironmentKey {
  static var defaultValue: AlignmentID?
}


Review comment (suggestion):
I don't actually think we want that diagnostic anyway, it was because we picked a subscript overload that expected a metatype argument and was read-only, so it seems pretty unlikely that's what was expected here

Code after:
// RUN: %target-typecheck-verify-swift -verify-ignore-unrelated -target %target-cpu-apple-macosx10.15 -swift-version 5
// REQUIRES: objc_interop
// REQUIRES: OS=macosx

import SwiftUI

extension HorizontalAlignment {
  private enum MyHorizontalAlignment: AlignmentID {
    static func defaultValue(in d: ViewDimensions) -> CGFloat { d.width }
  }
}

extension EnvironmentValues {
  var myHorizontalAlignment: AlignmentID? {
    get { fatalError() }
    set { self[\.MyHorizontalAlignmentEnvironmentKey.self] = newValue }
    // expected-error@-1 {{value of type 'EnvironmentValues' has no member 'MyHorizontalAlignmentEnvironmentKey'}}
    // expected-error@-2 {{missing argument label 'keyPath:' in subscript}}
  }
}

struct MyHorizontalAlignmentEnvironmentKey: EnvironmentKey {
  static var defaultValue: AlignmentID?
}